package com.apptravel.util;

import org.springframework.util.ResourceUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2012-1-13
 * Time: 14:55:11
 * To change this template use File | Settings | File Templates.
 */
public class uploadUtil {

    private static final String UPLOAD_CONF_PATH = "classpath:upload.properties";

	private static final String UPLOAD_DIR_KEY = "upload.dir";

	private static final String UPLOAD_HTTP_KEY = "upload.http";

    public static String getUploadDir(){
        Properties pros = new Properties();
		try{
			File confFile = ResourceUtils.getFile(UPLOAD_CONF_PATH);
			InputStream is = new FileInputStream(confFile);
			pros.load(is);
		}catch(Exception e){
			e.printStackTrace();
		}
        return pros.getProperty(UPLOAD_DIR_KEY);
    }

    public static String getUploadHttp(){
        Properties pros = new Properties();
		try{
			File confFile = ResourceUtils.getFile(UPLOAD_CONF_PATH);
			InputStream is = new FileInputStream(confFile);
			pros.load(is);
		}catch(Exception e){
			e.printStackTrace();
		}
        return pros.getProperty(UPLOAD_HTTP_KEY);
    }


}
